package com.neu.niuyuchao.dao;

import com.neu.commons.Dao.BaseDao;
import com.neu.commons.Utils.GenerateSqlDao;
import com.neu.commons.Utils.dbutils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapListHandler;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MgrInfoDaoImpl extends BaseDao{
    public int insert(Map<String,String> item){
        int row=0;
        GenerateSqlDao gs=new GenerateSqlDao("t_mgr_info",
                "mgr_id","seq_t_mgr_info");
        row=gs.insert(item);
        return row;
    }
    public List<Map<String,Object>> findAllDor(){
        List<Map<String,Object>> list=new ArrayList<>();
        String sql="select * from v_allnum";
        list=BaseDaoQuery(sql);
         return list;
    }
    public List<Map<String,Object>> dorCompare(int pageCount){
        List<Map<String,Object>> list=new ArrayList<>();
        String sql="select ceil(count(dor_build)/?)a from v_dorcompare";
        list=BaseDaoQuery(sql,pageCount);
//        System.out.println(list);
        return list;
    }
    public List<Map<String,Object>> findPage(int pageIndex, int pageNum) {
        List<Map<String, Object>> list=null;
        int end=pageIndex*pageNum;
        int begin=(pageIndex-1)*pageNum;
//        System.out.println(end+"\t"+begin);
        String sql="  select * " +
                " from " +
                " (select a.*, rownum  ro from" +
                " ( select * from v_dorcompare )a where rownum<=?)b" +
                " where ro>?";
        list=BaseDaoQuery(sql,end,begin);

        return list;
    }


}
